import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/3/3 21:18
 */

public class Solution {
    public String minWindow(String s,String t){
        char[] ss = s.toCharArray();
        char[] tt = t.toCharArray();

        int[] hash1 = new int[128];//统计字符串t中的频次
        int kinds = 0;//t中有多少种字符
        for(char ch : tt)
            if(hash1[ch]++ == 0) kinds++;
        int[] hash2 = new int[128];
        int minlen = Integer.MAX_VALUE, begin = -1;
        for(int left = 0,right = 0,count = 0;right < ss.length; right++){
            char in = ss[right];
            if(++hash2[in] == hash1[in]) count++;//进窗口与维护count
            while(kinds == count){//判断
                //更新结果
                if(right - left +1 < minlen){
                    begin = left;
                    minlen = right - left + 1;
                }
                char out = ss[left++];
                if(hash2[out]-- == hash1[out]) count--;//出窗口与维护count
            }
        }
        if(begin == -1) return new String();
        else return s.substring(begin,begin+minlen);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextLine()){
            String s = in.nextLine();
            String t = in.nextLine();
            Solution solution = new Solution();
            String result = solution.minWindow(s,t);
            System.out.println(result);
        }
    }
}
